package com.ssyt.yt1.day11.basetype;

class Car implements Cloneable {

	private String brand;
	private double price;

	public Car() {
		super();
	}

	public Car(String brand, double price) {
		super();
		this.brand = brand;
		this.price = price;
	}

	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	@Override
	public Car clone() throws CloneNotSupportedException {
		return (Car) super.clone();
	}
}

/**
 * 浅克隆
 * 
 * @author Administrator
 *
 */
public class ObjectShallowClone {

	public static void main(String[] args) throws CloneNotSupportedException {
		// int[] numbers1 = { 1, 2, 23, 41, 234 };
		// int[] number2 = numbers1.clone();
		// for (int i : number2) {
		// System.out.println(i);
		// }

		// 只克隆内容，对象还是各自的！
		Car car1 = new Car("宝马x钱", -1060000);
		Car car2 = car1.clone();
		System.out.println(car1 + ", " + car1.getBrand() + ","
				+ car1.getPrice());
		System.out
				.println(car2 + "," + car2.getBrand() + "," + car2.getPrice());
	}
}
